package base_code2.prizeDemo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,10,5,20,50,100,200,500,800,400,70);

        MyCallable mc = new MyCallable(list);
        FutureTask<Integer> ft1 = new FutureTask<>(mc);
        FutureTask<Integer> ft2 = new FutureTask<>(mc);

        Thread t1 = new Thread(ft1);
        Thread t2 = new Thread(ft2);

        t1.setName("1");
        t2.setName("2");

        t1.start();
        t2.start();

        //通过管理工具的get获取数据
        int max1 = ft1.get();
        int max2 = ft2.get();

        System.out.println( "1: " + max1);
        System.out.println( "2: " + max2);
    }
}
